package com.mdz.sbgl.Controller;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mdz.sbgl.Entity.Fwdzb;
import com.mdz.sbgl.Entity.Sbxxb;
import com.mdz.sbgl.Mapper.FwdzbMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 孟德志
 * @since 2023-08-30
 */
@Controller
@RequestMapping("/sbgl/fwdzb")
public class FwdzbController {

    @Autowired
    private FwdzbMapper fwdzbMapper;

    @Autowired
    private HttpServletRequest request;

    /*
     * 显示fwdzb所有数据
     */
    @ResponseBody
    @RequestMapping(value = "/getfwdzbbygsid", method = RequestMethod.GET)
    public String getfwdzbbygsid(@RequestParam int pageNumber, @RequestParam int pageSize, HttpServletResponse response) {
        String gsid = request.getParameter("gsid");
        response.setContentType("text/json");
        response.setCharacterEncoding("utf-8");
        PageHelper.startPage(pageNumber, pageSize);
        List<Fwdzb> ncList = fwdzbMapper.selectList(new QueryWrapper<Fwdzb>().eq("gsid", gsid));
        PageInfo page = new PageInfo(ncList);
        List<Fwdzb> rows = page.getList();
        int total = (int) page.getTotal();
        JSONObject result = new JSONObject();
        result.put("rows", rows);
        result.put("total", total);
        return result.toJSONString();
    }

}

